package com.bjpowernode.pay;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.bjpowernode.pay.config.AlipayConfig;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import javax.annotation.Resource;

@EnableDubbo
@SpringBootApplication
public class P2pPayApplication {

	@Resource
	private AlipayConfig alipayConfig;

	@Bean
	public AlipayClient alipayClient(){
		//获得初始化的AlipayClient
		AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig.gatewayUrl,
				alipayConfig.app_id,
				alipayConfig.merchant_private_key,
				"json", alipayConfig.charset,
				alipayConfig.alipay_public_key,
				alipayConfig.sign_type);

		return alipayClient;
	}

	public static void main(String[] args) {
		SpringApplication.run(P2pPayApplication.class, args);
	}

}
